<?php

/**
* 跨境电商商城系统
 * =============================================
 * Copy right 2016-2026 大连熠泽科技网络有限公司
 * ---------------------------------------------
 * 官方网址: http://www.yizehuitong.com
 * =============================================
 * @author : yizehuitong
 * @date : 2019.10
 * @version : v2.0
 */

namespace addons\NsGroupBuy\api\controller;

use app\api\controller\BaseApi;
use addons\NsGroupBuy\data\service\GroupBuy as GroupBuyService;

/**
 * 团购接口
 */
class GroupBuy extends BaseApi
{
	
	/**
	 * 团购商品列表
	 */
	public function goodsList()
	{
		$title = "团购专区商品列表";
		$group_buy_service = new GroupBuyService();
		$page_index = isset($this->params['page_index']) ? $this->params['page_index'] : 1;
		$page_size = isset($this->params['page_size']) ? $this->params['page_size'] : PAGESIZE;
		$condition = array(
			"state" => 1,
			"npgb.start_time" => array(
				"<",
				time()
			),
			"npgb.end_time" => array(
				">",
				time()
			),
            // 只查询当前端口下的商品
            'ng.category_id_1' => ['in', $this->category_ids]
		);
		$field = 'ng.goods_id,ng.promotion_price,ng.goods_name,ng.picture,npgb.group_id,npgb.group_name,npgb.shop_id,npgb.goods_id,npgb.start_time,npgb.end_time,npgb.max_num,npgb.min_num,npgb.status';
		$group_goods_list = $group_buy_service->getPromotionGroupBuyGoodsList($page_index, $page_size, $condition, 'npgb.group_id desc', $field);
		return $this->outMessage($title, $group_goods_list);
	}
}